<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <!-- 反扒 -->
    <meta name="referrer" content="never">
    <link rel="stylesheet" href="./css/base.css">
    <script src="./js/common.js"></script>
    <script src="./js/vue.js"></script>
    <script src="./datas/home.js"></script>
    <title>电影首页</title>
    <script>
        window.onload = function () {
            var vvm = new Vue({
                el: ".app",
                data:{
                    list:homeData.result,
                    home:homeData,
                    flag:true,
                    te:"暂无评分"
                },
                methods: {
                    // 获得焦点
                    focusIn(){
                        let seachBtn = document.querySelector("#seachBtn");
                        seachBtn.style.display = "block";
                    },
                    // 失去焦点
                    blurOut(){
                        let userInput = document.querySelector("#userInput");
                        let seachBtn = document.querySelector("#seachBtn");
                        seachBtn.style.display = "none";
                        userInput.value = "";
                    }
                },
            })
            // console.log(vvm.home)
            // console.log(vvm.list)
            // // 搜索框功能
            // let userInput = document.querySelector("#userInput");
            // let seachBtn = document.querySelector("#seachBtn");
            // userInput.onfocus = function () {
            //     seachBtn.style.display = "block";
            // }
            // userInput.onblur = function () {
            //     seachBtn.style.display = "none";
            //     userInput.value = "";
            // }
        }
    </script>
</head>

<body>
    <!-- 项目容器 start-->
    <div class="app">
        <!-- 头部搜索框 start -->
        <nav class="nav-box">
            <div class="nav-input">
                <input id="userInput" type="text" v-on="{ focus:focusIn,blur:blurOut }">
            </div>
            <div id="seachBtn" class="nav-btn">
                <span>搜索</span>
            </div>
        </nav>
        <!-- 头部搜索框 end -->
        <!-- 首页正文 start -->
        <div class="content-box">
            <div class="home-box" v-cloak>
                <!-- 首页分类列表 start -->
                <div v-for="(v,i) in list ">
                    <div class="list-name">
                        <span>热门电影</span>
                        <span class="list-more">更多 > </span>
                    </div>
                    <div class="list-content">
                        <!-- 电影展示组件 start -->
                        <div class="film-item" v-for=" (x, k) in v.list ">
                            <div class="film-img" :style="{backgroundImage:'url(' + x.filmImg + ')'}"></div>
                            <div class="film-title">{{x.filmName}}</div>
                            <div class="film-source" v-if="x.source?flag = true:flag = false">
                                <span class="star-img open" v-for=" n in Math.floor(x.source / 2) "></span>
                                <span class="star-img close" v-for=" n in 5-Math.floor(x.source / 2) "></span>
                                <span class="star-source">{{x.source}}</span>
                            </div>
                            <div class="film-source" v-if="!flag">
                                <span class="star-tip">{{te}}</span>
                            </div>
                        </div>
                        <!-- 电影展示组件 end -->
                    </div>
                </div>
                <!-- 首页分类列表 end -->
            </div>
        </div>
        <!-- 首页正文 end -->
    </div>
    <!-- 项目容器 end-->
</body>

</html>